package com.asuka.controller.user;

import com.asuka.dto.ShoppingCartDTO;
import com.asuka.entity.ShoppingCart;
import com.asuka.result.Result;
import com.asuka.service.ShoppingCartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/user/shoppingCart")
@RestController
@Slf4j
public class ShoppingCartController {


    @Autowired
    private ShoppingCartService shoppingCart;

    @PostMapping("/add")
    public Result addShop(@RequestBody ShoppingCartDTO shoppingCartDTO){

        shoppingCart.add(shoppingCartDTO);

        return Result.success();
    }


    @GetMapping("/list")
    public Result<List<ShoppingCart>> list(){
        List<ShoppingCart> list = shoppingCart.list();
        return Result.success(list);
    }


    @DeleteMapping("/clean")
    public Result clean(){
        shoppingCart.clean();
        return Result.success();
    }


}
